import java.io.*;
import java.util.*;

public class Main {
	BufferedReader bf;
	StringTokenizer st;
	StringBuilder sb = new StringBuilder();

	int n;
	int[][] road;
	
	public static void main(String[] args) {
		Main main = new Main();
		main.beginProcess();
	}

	public void beginProcess() {
		String input;
		int i;
		bf = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			while((input = bf.readLine()) != null) {
				st = new StringTokenizer(input);
				n = Integer.parseInt(st.nextToken());
				
				road = new int[n][3];
				for(i = 0; i < n; i++) {
					st = new StringTokenizer(bf.readLine());
					road[i][0] = Integer.parseInt(st.nextToken());
					road[i][1] = Integer.parseInt(st.nextToken());
					road[i][2] = Integer.parseInt(st.nextToken());
				}
				
				getAndSorting();
			}
			
			System.out.print(sb);
		}
		catch(Exception ex) {
			System.err.println(ex.toString());
		}
	}
	
	private void getAndSorting() {
		int i, j, len = n, tmp;
		for(i = 0; i < n - 1; i++) {
			for(j = 0; j < n - 1 - i; j++) {
				if(road[j][2] > road[j + 1][2]) {
					tmp = road[j][0];
					road[j][0] = road[j + 1][0];
					road[j + 1][0] = tmp;
					
					tmp = road[j][1];
					road[j][1] = road[j + 1][1];
					road[j + 1][1] = tmp;
					
					tmp = road[j][2];
					road[j][2] = road[j + 1][2];
					road[j + 1][2] = tmp;					
				}
			}
		}
		
		for(i = 0; i < n; i++)
			sb.append(road[i][0] + " " + road[i][1] + " " + road[i][2] + "\n");
	}
	
}